package com.company.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.company.project.common.aop.annotation.LogAnnotation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.company.project.common.utils.DataResult;

import com.company.project.entity.TCallbakEntity;
import com.company.project.service.TCallbakService;



/**
 * 
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2023-12-22 18:16:40
 */
@Controller
@RequestMapping("/")
public class TCallbakController {
    @Autowired
    private TCallbakService tCallbakService;


    /**
    * 跳转到页面
    */
    @GetMapping("/index/tCallbak")
    public String tCallbak() {
        return "tcallbak/list";
        }

    @ApiOperation(value = "新增")
    @PostMapping("tCallbak/add")
    @RequiresPermissions("tCallbak:add")
    @ResponseBody
    public DataResult add(@RequestBody TCallbakEntity tCallbak){
        tCallbakService.save(tCallbak);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("tCallbak/delete")
    @RequiresPermissions("tCallbak:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        tCallbakService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("tCallbak/update")
    @RequiresPermissions("tCallbak:update")
    @ResponseBody
    public DataResult update(@RequestBody TCallbakEntity tCallbak){
        tCallbakService.updateById(tCallbak);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("tCallbak/listByPage")
    @RequiresPermissions("tCallbak:list")
    @LogAnnotation(title = "未回拨", action = "查询分页数据")
    @ResponseBody
    public DataResult findListByPage(@RequestBody TCallbakEntity tCallbak){
        Page page = new Page(tCallbak.getPage(), tCallbak.getLimit());
        LambdaQueryWrapper<TCallbakEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(TCallbakEntity::getId, tCallbak.getId());
        IPage<TCallbakEntity> iPage = tCallbakService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
